package pso;


import discretePso.*;

public class MAXSAT extends BlackBoxFunction{
	private SATInstance instance;

	public MAXSAT(SATInstance instance){
		super(new Point(instance.numVariables,0), new Point(instance.numVariables,1));
		this.instance = instance;
	}
	

	@Override
	protected double evaluateHelper(Point p) {
		//Random r = new java.util.Random();
		boolean[] assignment = new boolean[p.getDimension()];
		for(int i=0; i<p.getDimension(); i++){
			assignment[i] = (p.getCoordinate(i) > 0.5);
		}
		return (instance.numClauses - instance.evaluate(assignment));
	}

}
